feat(mcp): Add opt-in idle timeout shutdown#398
Merged
cameroncooke merged 5 commits intomainfrom May 7, 2026
Merged
Conversation
Add an MCP server idle timeout controlled by XCODEBUILDMCP_MCP_IDLE_TIMEOUT_MS. The timeout is disabled by default and only shuts down after the server is idle, there are no in-flight MCP requests, and no registered runtime operations remain. Track JSON-RPC request lifecycles at the stdio transport boundary so the idle controller observes normal MCP requests without changing individual tool handlers. Add unit coverage and a process-level MCP e2e test that proves the real server exits gracefully after the configured idle timeout. Fixes #394 Co-Authored-By: Codex <noreply@openai.com>
commit: |
Avoid inflating the MCP idle in-flight counter when a client reuses a pending JSON-RPC request id. Also clear the pending request if downstream message handling throws synchronously before a response can be sent. Refs #394 Co-Authored-By: Codex <noreply@openai.com>
Move the real MCP process idle-timeout test out of snapshot tests because it asserts behavior directly and does not use snapshot fixtures. Refs #394 Co-Authored-By: Codex <noreply@openai.com>
Assert the real MCP server process remains running when no idle timeout is configured, then separately assert the opt-in timeout exits gracefully. Refs #394 Co-Authored-By: Codex <noreply@openai.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add an opt-in MCP server idle shutdown path controlled by
XCODEBUILDMCP_MCP_IDLE_TIMEOUT_MS.MCP mode previously stayed alive until the client disconnected or the process was otherwise terminated. This adds a default-disabled idle timeout that exits through the existing graceful lifecycle shutdown path once the configured idle period has elapsed, no MCP request is in flight, and no registered runtime operation is active.
The implementation tracks JSON-RPC request lifecycles at the stdio transport boundary so regular MCP requests, not just tool handlers, keep the server alive. It also adds unit coverage for parsing, timer behavior, lifecycle request tracking, and a process-level MCP e2e test that starts the built CLI and asserts the server exits cleanly after the configured timeout.
Fixes #394